package org.jsemantic.servicerules.examples.energy;

import org.jsemantic.servicerules.examples.energy.model.Invoice;

public class Process extends Thread {

	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger
			.getLogger(Process.class);

	private int counter = 10;

	public Process(int counter) {
		this.counter = counter;
	}

	public class ThreadHolder implements Runnable {

		public void run() {

			Invoice invoice = EnergyInvoiceApp.invoiceService.createInvoice(
					EnergyInvoiceApp.generator.getCustomer(),
					EnergyInvoiceApp.generator.getMeterReading());

			invoice = null;
		}
	};

	public void run() {
		for (int i = 0; i < counter; i++) {
			new Thread(new ThreadHolder()).start();
			try {
				sleep(100);
			} catch (InterruptedException e) {
				log.error(e);
			}
		}

	}

}
